﻿using Chess.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Chess.Controllers
{
    public class UserController : Controller
    {
        //
        // GET: /User/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Register()
        { 
            return View();
        }

        [HttpGet]
        public ActionResult Login()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Login(UserModel user)
        {
            if(user != null)
            {
                user.UserStatus = USER_STATUS.FREE;
                MvcApplication._Users.Add(user);
                Session["User"] = user;
                return RedirectToAction("Index", "Chess");    
            }
            return View();
        }
    }
}
